<template>
	<view style="margin-top: 150px;">
		 <text style="font-size: 25px;margin-left: 30px;">请输入\n\n</text>
		 <view style="margin-left: 80px;">
			 <view style="margin-bottom: 20px;">用户名:<input class="input_class" v-model="username" style="margin-right: 120px;"/></view>
			 <view style="margin-bottom: 20px;">密码 :<input class="input_class" v-model="password" style="margin-right: 120px;"/></view>
		 </view>
		 <view style="margin-top: 50px;margin-left: 80px;">
			 <button @click="regist()" style="width: 100px;margin-left: 100rpx">注册</button>
			 <text>\n注册成功后将返回登录页面</text>
		 </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username:"",
				password:""
			}
		},
		methods: {
			regist(){
				var username=this.username;
				var password=this.password;
				if(username=="" || username==null || password=="" || password==null){
					uni.showToast({title: '密码或账号不能为空！'});
					return;
				}
				uni.request({
					url:this.requestUrl+"/ForeUserController/addUser",
					method:"POST",
					data:{username:username,password:password},
					success:response => {
						if(response.data.code==200){
							uni.navigateTo({url:'../login/login'});					
						}else{
							uni.showToast({title: '账号已被注册！'});
						}
                        
					}
				})
			}
		}
	}
</script>

<style>
.input_class{
	background: #F1F1F1;
	width: 375rpx;
}
</style>
